from langchain.chains import ConversationChain
from langchain.memory import ConversationBufferWindowMemory

if __name__ == '__main__':
    # k=1表明只保留一个对话记忆
    memory = ConversationBufferWindowMemory(k=1)
    memory.save_context({"input": "你好，我叫皮皮鲁"}, {"output": "你好啊，我叫鲁西西"})
    memory.save_context({"input": "很高兴和你成为朋友!"}, {"output": "是的，让我们一起去冒 险吧!"})
    memory_info = memory.load_memory_variables({})
    print(memory_info)
